package com.stormdemo.wclocalhost.bolt;

import org.apache.commons.lang.StringUtils;

import backtype.storm.topology.BasicOutputCollector;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseBasicBolt;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import backtype.storm.tuple.Values;

public class transfBolt extends BaseBasicBolt {

	@Override
	public void declareOutputFields(OutputFieldsDeclarer declarer) {
		declarer.declare(new Fields("transf"));
	}

	@Override
	public void execute(Tuple input, BasicOutputCollector collector) {
		String src = input.getStringByField("word");
		for (String word : src.split(",")) {
			word = word.trim();
			if (StringUtils.isNotBlank(word)) {
				collector.emit(new Values(word));
			}
		}
	}
}
